import request from '_utils/request'
// 单独封装 不同接口请求

// 获取分类Cate
const fetchCates = (params = {}) => request.get('/shop/goods/category/all', { params })
// 获取首页banner
const fetchHomeBanner = (params = {}) => request.get('/banner/list', { params })
// 商品列表数据
const fetchItems = (params = {}) => request.post('/shop/goods/list/v2', params)
//  详情页商品数据
const fetchDetailItem = (id) => request.get('/shop/goods/detail', { params: { id } })
// 用户注册
const userRegister = (params = {}) => request.post('/user/username/register', params)
// 用户登录
const userLogin = (params = {}) => request.post('/user/username/login', params)
// 获取购物车
const fetchCartItems = (params = {}) => request.get('/shopping-cart/info', { params })
// 添加购物车
const addCart = (params = {}) => request.post('/shopping-cart/add', params)
// 购物车商品选中数量
const setByNumber = (params = {}) => request.post('/shopping-cart/modifyNumber', params)
// 商品的选中状态
const switchCheck = (params = {}) => request.post('/shopping-cart/select', params)
// 删除商品
const delCartItem = (params = {}) => request.post('/shopping-cart/remove', params)
// 获取收货地址列表
const fetchContacts = (params = {}) => request.post('/user/shipping-address/list/v2', params)
// 新增收货地址
const addContact = (params = {}) => request.post('/user/shipping-address/add', params)
// 获取收货地址详情
const fetchContactInfo = (params = {}) => request.get('/user/shipping-address/detail/v2', { params })
// 修改收货地址
const updateContact = (params = {}) => request.post('/user/shipping-address/update', params)

export {
  fetchCates,
  fetchHomeBanner,
  fetchItems,
  fetchDetailItem,
  userRegister,
  userLogin,
  fetchCartItems,
  addCart,
  setByNumber,
  switchCheck,
  delCartItem,
  fetchContacts,
  addContact,
  fetchContactInfo,
  updateContact
}
